//
//  LinkVC.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/21.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "LinkVC.h"
#import "VideoVC.h"

@interface LinkVC ()
// 记录状态   是push  还是 pop  然后根据需求来调整导航栏
@property (nonatomic, assign) BOOL isPush;
@end

@implementation LinkVC



- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    self.isPush = NO;
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    if (!self.isPush) {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    }
    
}




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"添加链接";
    self.view.backgroundColor = [UIColor whiteColor];
     self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"icon_close" highImageName:@"icon_close" target:self action:@selector(back)];
    [self loadSubviewsOnLinkView];
}

- (void)back{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)loadSubviewsOnLinkView{
    UIView *topLineView = [[UIView alloc]init];
    topLineView.backgroundColor = KLColor_B3;
    [self.view addSubview:topLineView];
    [topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(1);
    }];
    
    
    UITextField *linkAddressTF = [[UITextField alloc]init];
    linkAddressTF.backgroundColor = KLColor_C1;
    linkAddressTF.placeholder = @"请输入网页链接";
    linkAddressTF.textColor = KLColor_B6;
    linkAddressTF.textAlignment = NSTextAlignmentCenter;
    linkAddressTF.layer.masksToBounds = YES;
    linkAddressTF.layer.cornerRadius = 4*WIDTH;
    linkAddressTF.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16*WIDTH];
    [self.view addSubview:linkAddressTF];
    [linkAddressTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.width.mas_equalTo(345*WIDTH);
        make.height.mas_equalTo(60*HEIGHT);
        make.top.equalTo(self.view).offset(48*HEIGHT);
    }];
    
    
    UILabel *alertTint = [[UILabel alloc]init];
    alertTint.text = @"支持秒拍、微博视频链接内容提取，在链接输入框内粘贴你想发表的视频链接地址，会自动展示出链接地址里的视频";
    alertTint.textColor = KLColor_B8;
    alertTint.numberOfLines = 0;
    alertTint.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
    [self.view addSubview:alertTint];
    [alertTint mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(linkAddressTF.mas_bottom).offset(26*HEIGHT);
        make.width.mas_equalTo(313*WIDTH);
        make.height.mas_equalTo(52*HEIGHT);
    }];


    // 发布的button
    UIButton *publishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [publishBtn setTitle:@"添加" forState:UIControlStateNormal];
    [publishBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    publishBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16*WIDTH];
    publishBtn.backgroundColor = KLColor_A1;
    publishBtn.layer.masksToBounds= YES;
    publishBtn.layer.cornerRadius = 22*HEIGHT;
    [[publishBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(UIButton *publishBtn) {
        VideoVC *videoVc = [[VideoVC alloc]init];
        [self.navigationController pushViewController:videoVc animated:YES];
        self.isPush = YES;
    }];
    [self.view addSubview:publishBtn];
    [publishBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(alertTint.mas_bottom).offset(76*HEIGHT);
        make.height.mas_equalTo(44*HEIGHT);
        make.width.mas_equalTo(345*WIDTH);
    }];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
